package o;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.Iterator;

public final class duj {
    private static volatile duj ॱ;
    private final Object ˊ = new Object();
    private final ArrayList<a> ˏ = new ArrayList();

    static class a {
        private static final duf ˎ = new duf() {
            public void ˏ(Object... objArr) {
                Logger.e("CallDispatch", "This is empty implement for ICall.");
            }
        };
        private final Class<? extends duf> ˊ;

        a(@NonNull Class<? extends duf> cls) {
            this.ˊ = cls;
        }

        @NonNull
        Class<? extends duf> ˎ() {
            return this.ˊ;
        }

        @NonNull
        duf ˋ() {
            duf ॱ = ॱ();
            if (ॱ == null) {
                return ˎ;
            }
            return ॱ;
        }

        @Nullable
        private duf ॱ() {
            try {
                return (duf) this.ˊ.newInstance();
            } catch (Exception e) {
                Logger.e("CallDispatch", "Fail to new instance for: " + this.ˊ);
                return null;
            }
        }
    }

    public static duj ˏ() {
        if (ॱ == null) {
            synchronized (duj.class) {
                if (ॱ == null) {
                    ॱ = new duj();
                }
            }
        }
        return ॱ;
    }

    private duj() {
    }

    public void ˊ(Class<? extends duf> cls) {
        if (cls != null) {
            synchronized (this.ˊ) {
                this.ˏ.add(new a(cls));
            }
        }
    }

    public void ˎ(Class<? extends duf> cls, Object... objArr) {
        Iterator it = ˎ(cls).iterator();
        while (it.hasNext()) {
            ((duf) it.next()).ˏ(objArr);
        }
    }

    @NonNull
    private ArrayList<duf> ˎ(Class<? extends duf> cls) {
        ArrayList<duf> arrayList = new ArrayList();
        if (cls != null) {
            synchronized (this.ˊ) {
                Iterator it = this.ˏ.iterator();
                while (it.hasNext()) {
                    a aVar = (a) it.next();
                    if (cls.isAssignableFrom(aVar.ˎ())) {
                        arrayList.add(aVar.ˋ());
                    }
                }
            }
        }
        return arrayList;
    }
}
